$(function () {

    /*轮播图*/
    $(".swiper-container").swiper({
        loop: true,
        speed: 300,
        autoplay: 5000,
        autoplayDisableOnInteraction: false,
        // 如果需要分页器
        pagination: '.swiper-pagination'

    });
    /*详细地址输入框*/
    $("#address-more").focus(function () {
        let $label = $(".js-address_label");
        if (!$label.is(":hidden")) {
            $label.hide();
        }
    });
    $("#address-more").blur(function () {
        let $label = $(".js-address_label");
        let input_value = $("#address-more").val();
        // console.log(input_value);
        if ($label.is(":hidden") && input_value === "") {
            $label.show();
        }
    });
    /*地址栏*/
    //获取默认地址栏
    (function addressDefault() {
        var city_all = $("#city-picker").val();
        var arr_city = city_all.split(" ");
        var last_num = arr_city.length - 1;
        $("#city-picker").parent(".m-address-bar_city").children("span").text(arr_city[last_num]);
        console.log(city_all);
    }());
    $("#city-picker").cityPicker({
        title: "请选择收货地址",
        showDistrict: false,
        onChange: function (picker, values, displayValues) {
            var last_num = displayValues.length - 1;
            console.log(values, displayValues[last_num]);
            $(this).parent(".m-address-bar_city").children("span").text(displayValues[last_num]);
        }
    });

    /*滚动刷新*/
    var loading = false;  //状态标记
    var html_add=`<a href="javascript:;" class="weui-media-box weui-media-box_appmsg">
                        <div class="weui-media-box__hd"><img src="asset/images/banner/sucai3.jpg" alt="" class="weui-media-box__thumb"></div>
                        <div class="weui-media-box__bd">
                            <h4 class="weui-media-box__title">某某足浴店-add</h4>
                            <p class="weui-media-box__desc m-media_box_help g-c--orange">绍兴市越城区迪荡湖路321号</p>
                            <p class="weui-media-box__desc">本药店主打药浴足浴，百年老字号中药足浴配方。本药店主打药浴足浴，百年老字号中药足浴配方。</p>
                            <div class="m-info-help g-ta--r">
                                <p class="m-help-text">距离：≤100米</p>
                            </div>
                        </div>
                        <i class="iconfont icon-enter"></i>
                    </a>`;
    $(document.body).infinite(0).on("infinite", function() {
        console.log("loading");
        /*if(loading) return;
        loading = true;
        setTimeout(function() {
            $(".js-weui-panel--shop").append(html_add);
            loading = false;
        }, 1500);   //模拟延迟*/
    });


});
